<%--@ page language="java" import="java.util.*" pageEncoding="UTF-8"--%>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String url = request.getParameter("url");
%>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html>
	<head>
		<base href="<%=basePath%>">
		<title>选择导入文件</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />  
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css" href="<%=path %>/web/style/layout.css" />
    <script type="text/javascript" src="<%=path %>/jqGrid/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=path %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
		<c:if test="${requestScope.message!=null}">
			<script type="text/javascript">
  	 			alert('<c:out value="${requestScope.message}"></c:out>');
  	 			window.close();
  			</script>
		</c:if>
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

	<script type="text/javascript">
	var type = '<%=request.getParameter("type") %>';
	 $().ready(function() {
		 function chexkAll(){
		 	var filename = document.getElementById('filePath').value;
		   var endname = filename.substring(filename.length-4);
		   if(endname != '.xls'){
			   alert("请选择成件系统数据，以xls为后缀文件");
			   return false;
		   }
			return true; 
		 }

		// 准备好Options对象
	    	var options = {
	    	    url:'<%=request.getContextPath() %>/'+type+'',
	    	    beforeSubmit: function() {
	    		   var date =  $('#pageFrom').form('enableValidation').form('validate');
	    		   if(!date){
						return false;
		    		  }
	    		    return chexkAll();
	    		},
	    	    dataType:'json',
	    	    success: function(data) {
	    	      if(data.result=='success'){
						if(data.msg=='msgKong'){
						    alert("第"+data.dangqianhangshu+"行数据中仓库名称、备件代码或者备件名称存在空值，数据导入失败！")
						}
						else if(data.msg=='msgErrorDep'){ 
							alert("第"+data.dangqianhangshu+"行数据中仓库(部门)名称不存在，数据导入失败！");
						}
						else if(data.msg=='msgErrorCF'){
							alert("第"+data.dangqianhangshu+"行数据中备件代码已存在，数据导入失败！");							
						}
						else if(data.msg=='msgErrorSup'){
							alert("第"+data.dangqianhangshu+"行数据中供应商名称不存在，数据导入失败！");
						}
						else if(data.msg=='msg'){
							alert("导入成功！");
							}
						window.close();
	    	      }else{
	    	      	alert("系统忙，请稍后重试！");
	    	      	return;
	    	      }
	    	    }};
			$('#saveBtn').click(function(){
				$('#pageFrom').ajaxSubmit(options);
				return false;
			});
	 });
	function closeqa(){
	window.close();
	}
	 
	</script>
	</head>
	<body>
		<form action="" id="pageFrom" enctype="multipart/form-data" method="post">
			<table width="100%"  border="0" align="center" cellpadding="5" cellspacing="5" class="formTableNew">
			<tr align="center">
			   <td align="right">选择文件：</td>
				<td align="left">
					<input type="file" name="filePath" id="filePath" style="border: 1px solid #999;padding: 5px;width: 260px;height:25px;" >
				    <a href="<%=request.getContextPath()%>/view/importMB/equipmentparts.zip" style="">模板下载</a>
				</td>
			</tr>
			<tr></tr></br>
			<tr></tr></br>

			<tr align="center">
				<td colspan="2" align="center">
					<input type="button" id="saveBtn" value="确 定" class="form_bt_orange" />
					<input type='button' value='取 消' onclick="closeqa();" class="form_bt_grey"/>
				</td>
			</tr>
			</table>
		</form>
	</body>
</html>
